var gulp = require('gulp'),
    jshint = require('gulp-jshint');
    concat = require('gulp-concat');
    rename = require('gulp-rename');
    uglify = require('gulp-uglify');
    paths = {
        root: './',
        lib: {
            root: 'lib/build/js/'
        },
        src:{
            root: 'src/js/'
        }
    };

    framework = {
        filename: 'framework',
        jsFiles: [
            'lib/framework7/js/wrap-start.js',
            'lib/framework7/js/f7-intro.js',
            'lib/framework7/js/views.js',
            'lib/framework7/js/navbars.js',
            //'lib/framework7/js/searchbar.js',
            //'lib/framework7/js/messagebar.js',
            'lib/framework7/js/xhr.js',
            'lib/framework7/js/pages.js',
            'lib/framework7/js/router.js',
            'lib/framework7/js/modals.js',
            'lib/framework7/js/progressbar.js',
            'lib/framework7/js/panels.js',
            'lib/framework7/js/lazy-load.js',
            //'lib/framework7/js/material-preloader.js',
            //'lib/framework7/js/messages.js',
            'lib/framework7/js/swipeout.js',
            //'lib/framework7/js/sortable.js',
            'lib/framework7/js/smart-select.js',
            //'lib/framework7/js/virtual-list.js',
            'lib/framework7/js/pull-to-refresh.js',
            'lib/framework7/js/infinite-scroll.js',
            'lib/framework7/js/scroll-toolbars.js',
            //'lib/framework7/js/material-tabbar.js',
            'lib/framework7/js/tabs.js',
            'lib/framework7/js/accordion.js',
            'lib/framework7/js/fast-clicks.js',
            'lib/framework7/js/clicks.js',
            'lib/framework7/js/resize.js',
            'lib/framework7/js/forms-storage.js',
            //'lib/framework7/js/forms-ajax.js',
            //'lib/framework7/js/forms-textarea.js',
            //'lib/framework7/js/material-inputs.js',
            'lib/framework7/js/push-state.js',
            'lib/framework7/js/swiper-init.js',
            'lib/framework7/js/photo-browser.js',
            //'lib/framework7/js/autocomplete.js',
            'lib/framework7/js/picker.js',
            'lib/framework7/js/calendar.js',
            //'lib/framework7/js/notifications.js',
            'lib/framework7/js/template7-templates.js',
            'lib/framework7/js/plugins.js',
            'lib/framework7/js/init.js',
            'lib/framework7/js/f7-outro.js',
            'lib/framework7/js/dom7-intro.js',
            'lib/framework7/js/dom7-methods.js',
            'lib/framework7/js/dom7-ajax.js',
            'lib/framework7/js/dom7-utils.js',
            'lib/framework7/js/dom7-outro.js',
            'lib/framework7/js/proto-support.js',
            'lib/framework7/js/proto-device.js',
            'lib/framework7/js/proto-plugins.js',
            'lib/framework7/js/template7.js',
            'lib/framework7/js/swiper.js',
            'lib/framework7/js/wrap-end.js',

            'lib/underscore/underscore.js',

            'lib/api/js-api.js',
            'lib/api/reference.js',
            //'lib/framework7/plugins/toast.js',
            'lib/framework7/plugins/framework-init.js',

            'lib/framework7/plugins/share.js',
            'lib/framework7/plugins/jsonp.js',
            'lib/framework7/plugins/modals.js',
            'lib/framework7/plugins/searchbar.js',
            'lib/framework7/plugins/snackbar-notifications.js',
            'lib/framework7/plugins/add-navbar.js',
            //'lib/framework7/plugins/video.js',
            'lib/api/logs.js',
        ]
    };

    mylog = {
        filename: 'log',
        jsFiles: [
            'lib/api/logs.js',
        ]
    };


    // Concat & Minify JS
    gulp.task('minify', function(){
        return gulp.src(framework.jsFiles)
            .pipe(concat(framework.filename + '.js'))
            .pipe(gulp.dest(paths.lib.root))
            .pipe(gulp.dest(paths.src.root))
            .pipe(rename(framework.filename + '.min.js'))
            .pipe(uglify())
            .pipe(gulp.dest(paths.lib.root))
            .pipe(gulp.dest(paths.src.root));
    });


// Default
gulp.task('default', ['minify']);
